# +_+ coding:utf-8 +_+

import threading
import time
import jury
from plugins import  *
import fivemin_ma5_ma10_jury
from api import *


__author__ = 'cz'


class Judge(threading.Thread):
    _jury = jury.Jury()

    def __init__(self):
        super(Judge, self).__init__()
        #self._jury = hl_jury.HLJury()
        self._jury = fivemin_ma5_ma10_jury.FiveMin_MA5_MA10_Jury()
        pass

    def run(self):
        print "Judge run..."
        while True:
            buy,sell,price,count = self._jury.judge()
            if buy > 0:
                self.buy(sell,price, count)
            elif buy < 0:
                self.sell(sell,price, count)
            else:
                pass
            time.sleep(10)

    def buy(self, seller, price, count):
        print "[BUY-{0}] {1}:{2}".format(seller, price, count)

    def sell(self, seller, price, count):
        print "[SELL-{0}] {1}:{2}".format(seller,price, count)
